#!/usr/bin/python3
import sys
import re

def solution(mover):
    rows = []
    for line in sys.stdin:
        line = line.rstrip('\n')
        #print('|', line, '|')
        # exit on empty line
        if not line:
            # remove index row
            rows.pop()
            break
        rows.append([line[start:start + 3] for start in range(0, len(line), 4)])

    # transpose (and reverse row order)
    cols = [[rows[row][col] for row in range(len(rows))[::-1] if rows[row][col] != '   '] for col in range(len(rows[0]))]
    #print(cols)

    for line in sys.stdin:
        count, orig, dest = [int(group) for group in re.match(r'^move ([0-9]+) from ([0-9]+) to ([0-9]+)$', line.strip()).groups()]
        #print(count, orig, dest)
        mover(cols, count, orig - 1, dest - 1)
    #print(cols)

    print(''.join([col[-1][1] for col in cols]))

# part 1
def mover9000(cols, count, orig, dest):
    for i in range(count):
        cols[dest].append(cols[orig].pop())

# part 2
def mover9001(cols, count, orig, dest):
    [cols[dest].append(l) for l in cols[orig][-count:]]
    [cols[orig].pop() for i in range(count)]

if sys.argv[1] in '1':
    solution(mover9000)
else:
    solution(mover9001)